<template>
    <div class="minishop-discover ">
        <div class="plr15">
        <div class="top pt10">
            <swiper class="swiper" :indicator-dots="indicatorDots"
                :autoplay="autoplay" :interval="interval" :duration="duration">
                <template v-for="(item, i) in barnerList">
                    <block :key="i">
                        <swiper-item >
                            <img @click="link2(item.link_to)" :src="item.image" alt="">
                        </swiper-item>
                    </block>
                </template>
            </swiper>
            <!-- <img src="/static/images/wd-bg.png" alt=""> -->
        </div>
        <div class="pt15">
            <ClList 
                :loading="loading"
                :finished="finished"
                finishedText="没有更多了"
                @load="ListTip"
                :list="list">
                <div class="list pb15">
                    <div class="left-list">
                        <template  v-for="(item, i) in list">
                        <div @click="link('/index/jdfxxq?id='+ item.tipId)" class="item" v-if="i%2==0" :key="i">
                            <div class="inner">
                                <img class="photo" :src="item.cover" alt="">
                                <div class="pl10 pr10">
                                    <div class="pt8">
                                        <img class="v-middle weizhi" src="/static/images/weizhi.png" alt="">
                                        <span class="ml6 v-middle fs-12 c-575757">{{item.address}}</span>
                                    </div>
                                    <div class="fs-15 c-000 pt10">
                                        {{item.title}}
                                    </div>
                                    <div class="pt8 pb13 pt10">
                                        <img class="v-middle avatar" :src="item.avatar" alt="">
                                        <span class="v-middle ml6 c-858585 fs-12">{{item.nickname}}</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        </template>
                    </div>
                    <div class="right-list">
                        <template  v-for="(item, i) in list">
                        <div @click="link('/index/jdfxxq?id='+ item.tipId)" class="item" v-if="i%2==1" :key="i">
                            <div class="inner">
                                <img class="photo" :src="item.cover" alt="">
                                <div class="pl10 pr10">
                                    <div class="pt8">
                                        <img class="v-middle weizhi" src="/static/images/weizhi.png" alt="">
                                        <span class="ml6 v-middle fs-12 c-575757">{{item.address}}</span>
                                    </div>
                                    <div class="fs-15 c-000 pt10">
                                        {{item.title}}
                                    </div>
                                    <div class="pt8 pb13 pt10">
                                        <img class="v-middle avatar" :src="item.avatar" alt="">
                                        <span class="v-middle ml6 c-858585 fs-12">{{item.nickname}}</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        </template>
                    </div>
                </div>
            </ClList>
        </div>
        </div>
    </div>
</template>

<script>
import NavComponent from "@/components/nav/index";
import tipApi from "@/api/api-tip";
import otherApi from '@/api/api-other'
import ClList from "@/components/ClList"
export default {
    data () {
        return {
            list: [],
            loading: true,
            finished: false,
            pageIndex: 1,
            pageSize: 20,
            indicatorDots: true,
            vertical: false,
            autoplay: true,
            interval: 3000,
            duration: 500,
            barnerList: []
        }
    },
    watch: {
        '$store.getters.logined': {
            handler(n, o){
                if(n){
                    
                }
            }
        },
    },
    components: {
        ClList,
        NavComponent
    },
    onLoad(options){
        
    },
    mounted () {
        this.initPage()
    },
    onShow(){
        
    },
    methods: {
        initPage(){
            this.ListTip()
            this.ListBanner()
        },
        ListTip(reload){
            this.loading = true
            if(reload){
                this.pageIndex = 1
                this.finished = false
            }
            tipApi.ListTip({
                pageIndex: this.pageIndex,
                pageSize: this.pageSize
            }).then(data => {
                this.loading = false
                if(reload){
                    this.list = data.result.List
                } else {
                    this.list = this.list.concat(data.result.List)
                }
                this.finished = data.result.IsLastPage
                this.pageIndex++
            })
        },
        ListBanner(){
            otherApi.ListBanner({
                adTypes: [3]
            }).then(data => {
                this.barnerList = data.result
            })
        },
        getSysInfo() {
            const res = wx.getSystemInfoSync()
            return res
        },
    }
}
</script>

<style  lang="scss">
@import './scss/discover.scss';
</style>
